<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        <!--
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 -->
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:o="http://myfaces.apache.org/orchestra"
        >
<body>
<!--@elvariable id="pollPage" type="at.irian.demo.jsfatwork.view.page.PollPage"-->
<ui:composition template="/layout/base-form-template.xhtml">

    <ui:define name="content">
        <p:panel header="#{messages.poll_create}" toggleable="true">
            <h:panelGrid columns="3">
                <h:outputLabel for="topic" value="#{messages.poll_topic}:"/>
                <h:inputText id="topic" value="#{pollPage.currentPoll.topic}" label="#{messages.poll_topic}"/>
                <p:message for="topic" showSummary="false"/>

                <h:outputLabel for="description" value="#{messages.poll_description}:"/>
                <h:inputTextarea id="description" value="#{pollPage.currentPoll.description}" label="#{messages.poll_description}" cols="30" rows="5"/>
                <p:message for="description" showSummary="false"/>

                <h:outputLabel for="start" value="#{messages.poll_start_date}:"/>
                <p:calendar id="start" value="#{pollPage.currentPoll.startDate}" pattern="dd.MM.yyyy"/>
                <p:message for="start" showSummary="false"/>

                <h:outputLabel for="end" value="#{messages.poll_end_date}:"/>
                <p:calendar id="end" value="#{pollPage.currentPoll.endDate}" pattern="dd.MM.yyyy"/>
                <p:message for="end" showSummary="false"/>

                <h:outputLabel for="group" value="#{messages.poll_for_group}:"/>
                <h:selectOneMenu id="group" value="#{pollPage.selectedGroup}" label="#{messages.poll_group}">
                    <f:selectItems value="#{pollPage.groupList}"/>
                </h:selectOneMenu>
                <p:message for="group" showSummary="false"/>

                <h:outputLabel for="active" value="#{messages.poll_activate}:"/>
                <h:selectBooleanCheckbox id="active" value="#{pollPage.currentPoll.active}"/>
                <p:message for="active" showSummary="false"/>

                <h:outputLabel for="multiple" value="#{messages.poll_multiple_answers_allowed}:"/>
                <h:selectBooleanCheckbox id="multiple" value="#{pollPage.currentPoll.multipleAnswerMode}"/>
                <p:message for="multiple" showSummary="false"/>
            </h:panelGrid>
        </p:panel>

        <p:panel header="#{messages.poll_possible_answers}">
            <p:dataTable var="answer" value="#{pollPage.possibleAnswers}" paginator="true" paginatorPosition="bottom" rows="10">
                <p:column>
                    <h:commandLink action="#{pollPage.addNewAnswer}">
                        <h:graphicImage url="/images/icon_add.png"/>
                    </h:commandLink>
                </p:column>
                <p:column>
                    <f:facet name="header"><h:outputText value="#{messages.poll_answer_text}"/></f:facet>
                    <h:inputText id="answer_description" value="#{answer.description}" label="#{messages.poll_answer}"/>
                    <p:message for="answer_description" showSummary="false"/>
                </p:column>
                <p:column>
                    <h:commandLink action="#{pollPage.removeAnswer}">
                        <h:graphicImage url="/images/icon_delete.png"/>
                        <f:setPropertyActionListener value="#{answer}" target="#{pollPage.selectedAnswer}"/>
                    </h:commandLink>
                </p:column>
            </p:dataTable>
            <h:commandButton value="#{messages.poll_add_yes_no}" action="#{pollPage.addYesNoAnswers}"/>
        </p:panel>

        <h:panelGrid columns="2">
            <h:commandButton value="#{messages.button_save}" action="#{pollPage.createPoll}"/>
            <h:commandButton value="#{messages.button_cancel}" action="#{pollPage.cancel}" immediate="true"/>
        </h:panelGrid>
    </ui:define>
</ui:composition>
</body>
</html>
